import request from '@/utils/request'

/**
 * 发送消息
 * @param params
 */
export function sendMessage(params) {
  const data = {
    users: JSON.stringify(params && params.users || []),
    target_type: params.target_type,
    send_user: params.send_user,
    message: JSON.stringify(params && params.message || []),
    message_type: params.message_type
  }
  return request({
    url: '/hospital/im-kefu/messages',
    method: 'post',
    data
  })
}

/**
 * 获取用户状态
 * @param params
 */
export function getUserStatus(params) {
  const data = {
    'user_id': params && params.user_id ? params.user_id : undefined
  }
  return request({
    url: '/hospital/im-kefu/status',
    method: 'get',
    params: data
  })
}

/**
 * 获取离线消息数
 * @param params
 */
export function getOfflineMessages(params) {
  const data = {
    'user_id': params && params.user_id ? params.user_id : undefined
  }
  return request({
    url: '/hospital/im-kefu/offline-msg-count',
    method: 'get',
    params: data
  })
}
